const fs = require('fs');
const ws = fs.createWriteStream('./test2.txt');
// 监听可写流是否打开
ws.on('open',()=>{
    console.log('可写流打开了！！');
})
// 监听可写流关闭
ws.on('close',()=>{
    console.log('可写流关闭！！');
})
// 写入内容
ws.write('111');
ws.write('222');
ws.write('333');
// 写完后，手动关闭可写流
ws.end();